package controllers

import (
	"bestcore/base"
	"bestcore/common/response"

	"bestlyg/services"

	"github.com/gofiber/fiber/v2"
)

func init() {
	Controllers = append(Controllers, new(UserController))
}

type UserController struct{ base.BaseController }

func (controller *UserController) Install(app *fiber.App) {
	user := app.Group("/user")
	user.Get("/list", controller.List)
}

func (controller *UserController) List(c *fiber.Ctx) error {
	users, err := services.User.GetList()
	if err != nil {
		return response.Fail(c, err.Error())
	}
	return response.Success(c, users)
}
